#ifndef _DEV_HOTPLUG_H_
#define _DEV_HOTPLUG_H_

#include "common/common.h"
#include "json/json-usr.h"
#include "device/dev_common.h"


namespace iecas_ns
{
    enum UsbDevice
    {
        Usb_Unknown_Device = -1,
        Usb_Serial,
        Usb_Disk,
        Usb_Keyboard,
        Usb_Camera,
        Usb_Net,
        SDcard
    };

    enum UsbConnect
    {
        Usb_Unknown_Action = -1,
        Usb_Add,
        Usb_Remove
    };

    #define UEVENT_BUFFER_SIZE 2048

    class CDevHotplug
    {
		public:
			static shared_ptr<CDevHotplug> getInstance();
            CDevHotplug();
			bool init(void);
            void start(void);
		private:
			static shared_ptr<CDevHotplug> sm_intancePtr;
            void loop(void);
            int m_hotplug_sock;
            shared_ptr<CCommon> m_commonPtr;
            shared_ptr<CJsonUsr> m_jsonUsrPtr;
            shared_ptr<CDevCommon> m_devCommonPtr;
            void hotplugJudge(string sock_s);
            int deviceJudge(string sock_s, string &dev_s);
            int connectJudge(string sock_s);
            void usb_serial_handle(string dev_s, int connDir);
            void usb_disk_handle(string dev_s, int connDir);
            void usb_keyboard_handle(string dev_s, int connDir);
            void usb_camera_handle(string dev_s, int connDir);
            void usb_net_handle(string dev_s, int connDir);
            void sdcard_handle(string dev_s, int connDir);
            int64_t serial_last_t;
            int64_t disk_last_t;
            int64_t keyboard_last_t;
            int64_t camera_last_t;
            int64_t net_last_t;
            int64_t sdcard_last_t;
            string aos_ip;
    };
}

#endif